function myAxios(options={}){
    return new Promise(resolve=>{
        let {url,params,data,method="get"} = options;
        const obj = {
            method
        }
        if(method.toLowerCase()==="post"){
            obj.headers = {
                "Content-Type":"application/json"
            }
            obj.body = JSON.stringify(data);

            if(typeof data === "string"){
                obj.headers = {
                    "Content-Type":"application/x-www-form-urlencoded"
                }
                obj.body = data;
            }
        }

        if(params){
            url+="?"+Object.keys(params).map(key=>key+"="+params[key]).join("&");
        }

        fetch(url,obj).then(value=>{
            value.json().then(data=>{
                resolve({
                    data
                })
            })
        })
    })
}
myAxios.get = function(url,options={}){
    return this({
        url,
        ...options
    })
}
myAxios.post = function(url,data){
    return this({
        url,
        method:"post",
        data
    })
}